from dwspark.config import Config
from dwspark.models import MultiLang
# 日志
from loguru import logger
from dwspark.models import VoiceSynthesis

# 加载系统环境变量：SPARKAI_UID、SPARKAI_APP_ID、SPARKAI_API_KEY、SPARKAI_API_SECRET
# config = Config()
# 自定义key写入
# config = Config('14****93', 'eb28b****b82', 'MWM1MzBkOD****Mzk0')


if __name__ == '__main__':
    # 初始化配置
    # conf = Config(appid='06ebab34', apisecret='YzI4YjlmNGFhYjFmYTYyYWNlY2UyOWM4', apikey='31f704523a9c6d75f8aa7671e318e64b')
    conf = Config()
    
    logger.info('----------批式调用----------')
    model = VoiceSynthesis(conf, stream=False)
    params_with_training = {
        'text': "欢迎使用讯飞星火认知大模型。",
        'model_name': "new_model",
        'audio_path': './test.wav', # 音频需要宝子们根据要求录制
        # 'force_train': True,  # Force retraining
        'output_path': './new_output.mp3',
        'voice_model_config': 'voice_models.json'  # Add the voice_model_config to params
    }
    
    # Uncomment to run training and synthesis
    result = model.generate(params_with_training)
    logger.info(f"Training and synthesis result: {result}")